﻿#include "start.h"
#include "ui_start.h"
#include"mainwindow.h"
#include"choosemode.h"
#include<QPainter>
#include"mypushbutton.h"
#include<QTimer>
#include<QLabel>
start::start(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::start)
{
    ui->setupUi(this);
    //五子棋游戏选择按钮 废案
    //ui->pushButton->setIcon(QIcon(":/pic/wuziqi.png"));
    //本窗口
    setWindowIcon(QIcon(":/pic/start.png"));
    //设置窗口标题
    setWindowTitle("悦de棋");

    //五子棋进入按钮
    MyPushButton*fiveBtn=new MyPushButton(":/pic/Button1.png","五子棋");

    fiveBtn->setParent(this);
    fiveBtn->move(0.5*this->width()-0.5*fiveBtn->width(),0.4*this->height());
    connect(fiveBtn,&MyPushButton::clicked,this,[=](){
        fiveBtn->zoom1();
        fiveBtn->zoom2();

        //等动画演示完成再下一个场景
        QTimer::singleShot(300,this,[=](){
            //实例化选择五子棋模式场景
            fiveMod=new choosemode;
            //自身隐藏
            this->hide();
            //显示选择模式的场景
            fiveMod->show();
        });

    });
    //孔明棋进入按钮
    MyPushButton*kongmingBtn=new MyPushButton(":/pic/Button1.png","孔明棋");

    kongmingBtn->setParent(this);
    kongmingBtn->move(0.5*this->width()-0.5*kongmingBtn->width(),0.4*this->height()+100);
    connect(kongmingBtn,&MyPushButton::clicked,this,[=](){

        kongmingBtn->zoom1();
        kongmingBtn->zoom2();
        QTimer::singleShot(300,this,[=](){
            kongmingqi=new kongmingstart;
            this->hide();
            kongmingqi->show();
        });

    });
}

start::~start()
{
    delete ui;
}

void start::paintEvent(QPaintEvent *){
        //设置背景
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/pic/tachibanakanade.png");
    painter.drawPixmap(0,0,pix.width(),pix.height(),pix);
}
